<template>
  <div class="setting">
    <a href="javascript:;" class="iconfont icon-shezhi" @click="isSetting = true"></a>
    <div class="setting-wrap" v-show="isSetting" @click="isSetting = false">
      <div class="setting-box" @click.stop>
        <div class="setting-menu">
          <nav>
            <a
              v-for="(item, index) in settingMenu"
              :key="index"
              href="javascript:;"
              :class="{
                active: item.component == componentName
              }"
              @click="change(item)"
            >{{item.name}}</a>
          </nav>
        </div>
        <div class="setting-content">
          <component :is="componentName" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'setting',
  data () {
    return {
      isSetting: false,
      componentName: 'background-setting',
      settingMenu: [
        {
          name: '壁纸',
          component: 'background-setting',
          icon: ''
        },
        {
          name: '图标',
          component: 'iconSetting',
          icon: ''
        },
        {
          name: '时间',
          component: 'timeSetting',
          icon: ''
        },
        {
          name: '关于',
          component: 'aboutSetting',
          icon: ''
        }
      ]
    }
  },
  methods: {
    change (item) {
      this.componentName = item.component
    }
  }
}
</script>

<style lang="scss" scoped>
.setting {
  .iconfont {
    font-size: 18px;
    color: #fff;
    margin-right: 20px;
  }
  .setting-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 100;
    .setting-box {
      background: #fff;
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      width: 500px;
      @include flex(row, center, center);
      .setting-menu {
        width: 100px;
        height: 100%;
        background: #fff;
        nav {
          a {
            @include wh(100%, 40px);
            line-height: 40px;
            color: #333;
            font-size: 14px;
            padding: 0 20px;
            box-sizing: border-box;
            &.active {
              background: #f2f2f2;
            }
          }
        }
      }
      .setting-content {
        flex: 1;
        height: 100vh;
        background: #f2f2f2;
      }
    }
  }
}
</style>
